<#assign tab = tab />
<#assign entity = tab.typeName />
<#assign entityPackage = tab.fullTypeName?substring(0, tab.fullTypeName?last_index_of(".")) />
<#include "Copyright.ftl" />
package ${entityPackage};

import java.io.Serializable;

// import javax.persistence.*;
<#-- 擦妹，去重 -->
<#assign imps = [] />
<#list tab.ids + tab.columns as col>
    <#assign pname = col.javaFullTypeName?substring(0, col.javaFullTypeName?last_index_of(".")) />
    <#if pname != "java.lang" && !imps?seq_contains(col.javaFullTypeName)>
        <#assign imps = imps + [col.javaFullTypeName] />
    </#if>
</#list>
<#-- -->
<#list tab.oneToOne + tab.manyToOne + tab.oneToMany + tab.manyToMany as rel>
    <#assign typeName = rel.rel.fullTypeName />
    <#assign pname = typeName?substring(0, typeName?last_index_of(".")) />
    <#if pname != "java.lang" && !imps?seq_contains(typeName)>
        <#assign imps = imps + [typeName] />
    </#if>
</#list>
<#list imps as imp>
import ${imp};
</#list>

<#include "ClassComment.ftl" />
/**
 * @Table name="${tab.table}"
 */
// @Entity
// @Table(name = "${tab.table}")
public class ${entity} extends AuditEntity implements Serializable {
    private static final long serialVersionUID = 1L;

<#list tab.ids as id>
    /**
    * @Id name="${id.column}"
    */
    private ${id.javaTypeName} ${id.property}<#if id.javaFullTypeName == "java.lang.Boolean"> = Boolean.FALSE</#if>;

</#list>
<#list tab.columns as field>
    /**
     * @Column name="${field.column}"
     */
    private ${field.javaTypeName} ${field.property}<#if field.javaFullTypeName == "java.lang.Boolean"> = Boolean.FALSE</#if>;

</#list>
<#list tab.oneToOne as one>
    /**
     * @OneToOne joinColumn="${one.joinColumn}"
     */
    private ${one.rel.typeName} ${one.property};
</#list>

<#list tab.ids + tab.columns as field>
    <#if 0 lt field_index>

    </#if>
    public void set${field.property?cap_first}(${field.javaTypeName} ${field.property}) {
        this.${field.property} = ${field.property};
    }

    // @Column(name = "${field.column}")
    public ${field.javaTypeName} get${field.property?cap_first}() {
        return this.${field.property};
    }
</#list>
}
